package com.等待唤醒机制.阻塞队列来实现等待唤醒机制;


import java.util.concurrent.ArrayBlockingQueue;

public class Cook extends Thread{
    ArrayBlockingQueue<String> queue;

    public Cook(ArrayBlockingQueue<String> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true){
                //不断把面条放在阻塞队列中
            try {
                queue.put("面条");//放进去
                System.out.println("厨师放了一碗面条");//不用加锁
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

        }
    }
}
